package com.headcaselabs.lb.client;

import java.io.Serializable;

/* 
Copyright 2007, HeadCase Humanufacturing, Inc.

	Licensed under the Apache License, Version 2.0 (the "License"); you
	may not use this file except in compliance with the License. You may
	obtain a copy of the License at
	
	   http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
	implied. See the License for the specific language governing
	permissions and limitations under the License.
*/
/**
 * A DNS Query
 * @author Florian Leibert
 *
 */
public class Query implements Serializable {

	private static final long	serialVersionUID	= 9207490548892074574L;
	private String netClass = "IN";
	private String type;
	private String name;
	/**
	 * Default Constructor
	 *
	 */
	public Query() {
		// TODO Auto-generated constructor stub
	}
	/**
	 * Full Constructor
	 * @param type
	 * @param name
	 */
	public Query(String type, String name) {
		this.type = type;
		this.name = name;
	}
	
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the netClass
	 */
	public String getNetClass() {
		return netClass;
	}
	/**
	 * @param netClass the netClass to set
	 */
	public void setNetClass(String netClass) {
		this.netClass = netClass;
	}
	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((name == null) ? 0 : name.hashCode());
		result = PRIME * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Query other = (Query) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}

	
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer("");
		sb.append("Query: hash:");
		sb.append(hashCode());
		sb.append(" [ class: ");
		sb.append(netClass);
		sb.append(" ; name: ");
		sb.append(name);
		sb.append(" ; type: ");
		sb.append(type);
		sb.append("]");
		return sb.toString();
	}
	
	
	
}
